package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Product;
import cn.wolfcode.trip.base.query.ProductQueryObject;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IProductService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/products")
public class ProductController {

    @Autowired
    private IProductService productService;

    /**
     * 查询所有商品
     */
    @GetMapping
    public PageInfo listByState(ProductQueryObject qo) {
        return productService.query(qo);
    }

    /**
     * 根据id查询商品对应明细
     */
    @GetMapping("/{id}")
    public Product selectById(@PathVariable Long id) {

        return productService.selectById(id);
    }

}
